﻿using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using  XLua;

public class GuideTools : Editor
{
    [MenuItem("GTATools/GamePlay/生成新手引导",  false, 1)]
    public static void Generate()
    {
        string path = Directory.GetCurrentDirectory();
        Debug.Log($"path={path}");
        LuaEnv env = new LuaEnv();
        LuaTable package = env.Global.GetLuaTable("package");

        //搜索路径
        string luaSearchPath = package.Get<string>("path");
        luaSearchPath += $";{path}\\Lua\\?.lua;{path}\\Assets\\Scripts\\Modules\\Guide\\Editor\\?.lua";
        package.Set("path", luaSearchPath);
        //生成Lua文件的目录
        string generatePath = $"{path}\\Lua\\ui\\pages\\Guide\\data";
        env.Global.Set("generatePath", generatePath);
        
        
        Debug.Log($"{package.Get<string>("path")}");
        //env.AddBuildin("rapidjson", XLua.LuaDLL.Lua.LoadRapidJson);
        env.DoString($"require 'GuideToolsLua'");
        env.Dispose();
    }
}
